package com.yitiao.disruptor;

import com.lmax.disruptor.EventHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * <h3>消费者处理消息</h3>
 */
@Slf4j
public class OrderEventHandler implements EventHandler<MessageModel> {
    /**
     *
     */
    @Override
    public void onEvent(MessageModel message, long l, boolean b) throws Exception {
        try {
            //这里停止1000ms是为了确定消费消息是异步的
            log.info("消费者处理消息开始");
//            Thread.sleep(3000);
            if (message != null) {
                log.info("消费者消费的信息是：{}",message);
            }
        } catch (Exception e) {
            log.info("消费者处理消息失败");
        }
        log.info("消费者处理消息结束");
    }
}
